#!/usr/bin/env python3

import common
import shell_helpers
from shell_helpers import LF

class Main(common.TestCliFunction):
    def __init__(self):
        super().__init__(
            description='''\
https://github.com/cirosantilli/linux-kernel-module-cheat#automated-tests
'''
        )
        self.add_argument(
            '--size',
            default=1,
            type=int,
            help='''\
Size of the tests to run. Scale:

* 1: a few seconds and important
* 2: < 5 minutes and important or a few seconds and not too important
* 3: all
'''
        )

    def timed_main(self):
        run_args = self.get_common_args()
        test_boot_args = run_args.copy()
        test_boot_args['size'] = self.env['size']
        self.run_test(self.import_path_main('test-boot'), test_boot_args, 'test-boot')
        self.run_test(self.import_path_main('test-userland-full-system'), run_args, 'test-userland')
        self.run_test(self.import_path_main('test-baremetal'), run_args, 'test-baremetal')
        self.run_test(self.import_path_main('test-user-mode'), run_args, 'test-user-mode')
        self.run_test(self.import_path_main('test-gdb'), run_args, 'test-gdb')
        if self.env['emulator'] == 'gem5':
            gem5_unit_test_args = run_args.copy()
            gem5_unit_test_args['unit_tests'] = True
            self.run_test(self.import_path_main('build-gem5'), gem5_unit_test_args, 'gem5-unit-tests')

if __name__ == '__main__':
    Main().cli()

